\(\int \frac {\sin ^2(c+d x)}{a+b \sec (c+d x)} \, dx\) [205]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [F(-2)]
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 100 \[ \int \frac {\sin ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\frac {\left (a^2-2 b^2\right ) x}{2 a^3}-\frac {2 \sqrt {a-b} b \sqrt {a+b} \text {arctanh}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^3 d}+\frac {(2 b-a \cos (c+d x)) \sin (c+d x)}{2 a^2 d} \]

[Out]

1/2*(a^2-2*b^2)*x/a^3+1/2*(2*b-a*cos(d*x+c))*sin(d*x+c)/a^2/d-2*b*arctanh((a-b)^(1/2)*tan(1/2*d*x+1/2*c)/(a+b)
^(1/2))*(a-b)^(1/2)*(a+b)^(1/2)/a^3/d

Rubi [A] (verified)

Time = 0.24 (sec) , antiderivative size = 100, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.238, Rules used = {3957, 2944, 2814, 2738, 214} \[ \int \frac {\sin ^2(c+d x)}{a+b \sec (c+d x)} \, dx=-\frac {2 b \sqrt {a-b} \sqrt {a+b} \text {arctanh}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^3 d}+\frac {\sin (c+d x) (2 b-a \cos (c+d x))}{2 a^2 d}+\frac {x \left (a^2-2 b^2\right )}{2 a^3} \]

[In]

Int[Sin[c + d*x]^2/(a + b*Sec[c + d*x]),x]

[Out]

((a^2 - 2*b^2)*x)/(2*a^3) - (2*Sqrt[a - b]*b*Sqrt[a + b]*ArcTanh[(Sqrt[a - b]*Tan[(c + d*x)/2])/Sqrt[a + b]])/
(a^3*d) + ((2*b - a*Cos[c + d*x])*Sin[c + d*x])/(2*a^2*d)

Rule 214

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(Rt[-a/b, 2]/a)*ArcTanh[x/Rt[-a/b, 2]], x] /; FreeQ[{a, b},
x] && NegQ[a/b]

Rule 2738

Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x
]}, Dist[2*(e/d), Subst[Int[1/(a + b + (a - b)*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}
, x] && NeQ[a^2 - b^2, 0]

Rule 2814

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[b*(x/d)
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rule 2944

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*sin[(e_.)
 + (f_.)*(x_)]), x_Symbol] :> Simp[g*(g*Cos[e + f*x])^(p - 1)*(a + b*Sin[e + f*x])^(m + 1)*((b*c*(m + p + 1) -
 a*d*p + b*d*(m + p)*Sin[e + f*x])/(b^2*f*(m + p)*(m + p + 1))), x] + Dist[g^2*((p - 1)/(b^2*(m + p)*(m + p +
1))), Int[(g*Cos[e + f*x])^(p - 2)*(a + b*Sin[e + f*x])^m*Simp[b*(a*d*m + b*c*(m + p + 1)) + (a*b*c*(m + p + 1
) - d*(a^2*p - b^2*(m + p)))*Sin[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f, g, m}, x] && NeQ[a^2 - b^2,
0] && GtQ[p, 1] && NeQ[m + p, 0] && NeQ[m + p + 1, 0] && IntegerQ[2*m]

Rule 3957

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_.)*(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_))^(m_.), x_Symbol] :> Int[(g*Co
s[e + f*x])^p*((b + a*Sin[e + f*x])^m/Sin[e + f*x]^m), x] /; FreeQ[{a, b, e, f, g, p}, x] && IntegerQ[m]

Rubi steps \begin{align*} \text {integral}& = -\int \frac {\cos (c+d x) \sin ^2(c+d x)}{-b-a \cos (c+d x)} \, dx \\ & = \frac {(2 b-a \cos (c+d x)) \sin (c+d x)}{2 a^2 d}-\frac {\int \frac {-a b+\left (a^2-2 b^2\right ) \cos (c+d x)}{-b-a \cos (c+d x)} \, dx}{2 a^2} \\ & = \frac {\left (a^2-2 b^2\right ) x}{2 a^3}+\frac {(2 b-a \cos (c+d x)) \sin (c+d x)}{2 a^2 d}+\frac {\left (b \left (a^2-b^2\right )\right ) \int \frac {1}{-b-a \cos (c+d x)} \, dx}{a^3} \\ & = \frac {\left (a^2-2 b^2\right ) x}{2 a^3}+\frac {(2 b-a \cos (c+d x)) \sin (c+d x)}{2 a^2 d}+\frac {\left (2 b \left (a^2-b^2\right )\right ) \text {Subst}\left (\int \frac {1}{-a-b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{a^3 d} \\ & = \frac {\left (a^2-2 b^2\right ) x}{2 a^3}-\frac {2 \sqrt {a-b} b \sqrt {a+b} \text {arctanh}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{a^3 d}+\frac {(2 b-a \cos (c+d x)) \sin (c+d x)}{2 a^2 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.19 (sec) , antiderivative size = 96, normalized size of antiderivative = 0.96 \[ \int \frac {\sin ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\frac {2 \left (a^2-2 b^2\right ) (c+d x)+8 b \sqrt {a^2-b^2} \text {arctanh}\left (\frac {(-a+b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a^2-b^2}}\right )+4 a b \sin (c+d x)-a^2 \sin (2 (c+d x))}{4 a^3 d} \]

[In]

Integrate[Sin[c + d*x]^2/(a + b*Sec[c + d*x]),x]

[Out]

(2*(a^2 - 2*b^2)*(c + d*x) + 8*b*Sqrt[a^2 - b^2]*ArcTanh[((-a + b)*Tan[(c + d*x)/2])/Sqrt[a^2 - b^2]] + 4*a*b*
Sin[c + d*x] - a^2*Sin[2*(c + d*x)])/(4*a^3*d)

Maple [A] (verified)

Time = 0.70 (sec) , antiderivative size = 142, normalized size of antiderivative = 1.42

method result size
derivativedivides \(\frac {-\frac {2 \left (a +b \right ) b \left (a -b \right ) \operatorname {arctanh}\left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{3} \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {\frac {2 \left (\left (\frac {1}{2} a^{2}+a b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}+\left (a b -\frac {1}{2} a^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{\left (1+\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}\right )^{2}}+\left (a^{2}-2 b^{2}\right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{a^{3}}}{d}\) \(142\)
default \(\frac {-\frac {2 \left (a +b \right ) b \left (a -b \right ) \operatorname {arctanh}\left (\frac {\left (a -b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{\sqrt {\left (a -b \right ) \left (a +b \right )}}\right )}{a^{3} \sqrt {\left (a -b \right ) \left (a +b \right )}}+\frac {\frac {2 \left (\left (\frac {1}{2} a^{2}+a b \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}+\left (a b -\frac {1}{2} a^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{\left (1+\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}\right )^{2}}+\left (a^{2}-2 b^{2}\right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{a^{3}}}{d}\) \(142\)
risch \(\frac {x}{2 a}-\frac {x \,b^{2}}{a^{3}}-\frac {i b \,{\mathrm e}^{i \left (d x +c \right )}}{2 d \,a^{2}}+\frac {i b \,{\mathrm e}^{-i \left (d x +c \right )}}{2 d \,a^{2}}-\frac {\sqrt {a^{2}-b^{2}}\, b \ln \left ({\mathrm e}^{i \left (d x +c \right )}+\frac {b +i \sqrt {a^{2}-b^{2}}}{a}\right )}{d \,a^{3}}+\frac {\sqrt {a^{2}-b^{2}}\, b \ln \left ({\mathrm e}^{i \left (d x +c \right )}-\frac {i \sqrt {a^{2}-b^{2}}-b}{a}\right )}{d \,a^{3}}-\frac {\sin \left (2 d x +2 c \right )}{4 d a}\) \(176\)

[In]

int(sin(d*x+c)^2/(a+b*sec(d*x+c)),x,method=_RETURNVERBOSE)

[Out]

1/d*(-2*(a+b)*b*(a-b)/a^3/((a-b)*(a+b))^(1/2)*arctanh((a-b)*tan(1/2*d*x+1/2*c)/((a-b)*(a+b))^(1/2))+2/a^3*(((1
/2*a^2+a*b)*tan(1/2*d*x+1/2*c)^3+(a*b-1/2*a^2)*tan(1/2*d*x+1/2*c))/(1+tan(1/2*d*x+1/2*c)^2)^2+1/2*(a^2-2*b^2)*
arctan(tan(1/2*d*x+1/2*c))))

Fricas [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 258, normalized size of antiderivative = 2.58 \[ \int \frac {\sin ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\left [\frac {{\left (a^{2} - 2 \, b^{2}\right )} d x + \sqrt {a^{2} - b^{2}} b \log \left (\frac {2 \, a b \cos \left (d x + c\right ) - {\left (a^{2} - 2 \, b^{2}\right )} \cos \left (d x + c\right )^{2} - 2 \, \sqrt {a^{2} - b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )} \sin \left (d x + c\right ) + 2 \, a^{2} - b^{2}}{a^{2} \cos \left (d x + c\right )^{2} + 2 \, a b \cos \left (d x + c\right ) + b^{2}}\right ) - {\left (a^{2} \cos \left (d x + c\right ) - 2 \, a b\right )} \sin \left (d x + c\right )}{2 \, a^{3} d}, \frac {{\left (a^{2} - 2 \, b^{2}\right )} d x - 2 \, \sqrt {-a^{2} + b^{2}} b \arctan \left (-\frac {\sqrt {-a^{2} + b^{2}} {\left (b \cos \left (d x + c\right ) + a\right )}}{{\left (a^{2} - b^{2}\right )} \sin \left (d x + c\right )}\right ) - {\left (a^{2} \cos \left (d x + c\right ) - 2 \, a b\right )} \sin \left (d x + c\right )}{2 \, a^{3} d}\right ] \]

[In]

integrate(sin(d*x+c)^2/(a+b*sec(d*x+c)),x, algorithm="fricas")

[Out]

[1/2*((a^2 - 2*b^2)*d*x + sqrt(a^2 - b^2)*b*log((2*a*b*cos(d*x + c) - (a^2 - 2*b^2)*cos(d*x + c)^2 - 2*sqrt(a^
2 - b^2)*(b*cos(d*x + c) + a)*sin(d*x + c) + 2*a^2 - b^2)/(a^2*cos(d*x + c)^2 + 2*a*b*cos(d*x + c) + b^2)) - (
a^2*cos(d*x + c) - 2*a*b)*sin(d*x + c))/(a^3*d), 1/2*((a^2 - 2*b^2)*d*x - 2*sqrt(-a^2 + b^2)*b*arctan(-sqrt(-a
^2 + b^2)*(b*cos(d*x + c) + a)/((a^2 - b^2)*sin(d*x + c))) - (a^2*cos(d*x + c) - 2*a*b)*sin(d*x + c))/(a^3*d)]

Sympy [F]

\[ \int \frac {\sin ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\int \frac {\sin ^{2}{\left (c + d x \right )}}{a + b \sec {\left (c + d x \right )}}\, dx \]

[In]

integrate(sin(d*x+c)**2/(a+b*sec(d*x+c)),x)

[Out]

Integral(sin(c + d*x)**2/(a + b*sec(c + d*x)), x)

Maxima [F(-2)]

Exception generated. \[ \int \frac {\sin ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\text {Exception raised: ValueError} \]

[In]

integrate(sin(d*x+c)^2/(a+b*sec(d*x+c)),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*a^2-4*b^2>0)', see `assume?`
 for more de

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 185 vs. \(2 (86) = 172\).

Time = 0.32 (sec) , antiderivative size = 185, normalized size of antiderivative = 1.85 \[ \int \frac {\sin ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\frac {\frac {{\left (a^{2} - 2 \, b^{2}\right )} {\left (d x + c\right )}}{a^{3}} - \frac {4 \, {\left (a^{2} b - b^{3}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {-a^{2} + b^{2}}}\right )\right )}}{\sqrt {-a^{2} + b^{2}} a^{3}} + \frac {2 \, {\left (a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 2 \, b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 2 \, b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1\right )}^{2} a^{2}}}{2 \, d} \]

[In]

integrate(sin(d*x+c)^2/(a+b*sec(d*x+c)),x, algorithm="giac")

[Out]

1/2*((a^2 - 2*b^2)*(d*x + c)/a^3 - 4*(a^2*b - b^3)*(pi*floor(1/2*(d*x + c)/pi + 1/2)*sgn(-2*a + 2*b) + arctan(
-(a*tan(1/2*d*x + 1/2*c) - b*tan(1/2*d*x + 1/2*c))/sqrt(-a^2 + b^2)))/(sqrt(-a^2 + b^2)*a^3) + 2*(a*tan(1/2*d*
x + 1/2*c)^3 + 2*b*tan(1/2*d*x + 1/2*c)^3 - a*tan(1/2*d*x + 1/2*c) + 2*b*tan(1/2*d*x + 1/2*c))/((tan(1/2*d*x +
 1/2*c)^2 + 1)^2*a^2))/d

Mupad [B] (verification not implemented)

Time = 13.94 (sec) , antiderivative size = 147, normalized size of antiderivative = 1.47 \[ \int \frac {\sin ^2(c+d x)}{a+b \sec (c+d x)} \, dx=\frac {\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )-\frac {\sin \left (2\,c+2\,d\,x\right )}{4}}{a\,d}-\frac {2\,b^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{a^3\,d}+\frac {b\,\sin \left (c+d\,x\right )}{a^2\,d}-\frac {2\,b\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\sqrt {a^2-b^2}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (a+b\right )}\right )\,\sqrt {a^2-b^2}}{a^3\,d} \]

[In]

int(sin(c + d*x)^2/(a + b/cos(c + d*x)),x)

[Out]

(atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)) - sin(2*c + 2*d*x)/4)/(a*d) - (2*b^2*atan(sin(c/2 + (d*x)/2)/cos(
c/2 + (d*x)/2)))/(a^3*d) + (b*sin(c + d*x))/(a^2*d) - (2*b*atanh((sin(c/2 + (d*x)/2)*(a^2 - b^2)^(1/2))/(cos(c
/2 + (d*x)/2)*(a + b)))*(a^2 - b^2)^(1/2))/(a^3*d)